<?php
namespace App\Http\Controllers\Api;

use App\Models\Coach;
use App\Http\Resources\Api\CoachResource;

class CoachController extends Controller
{
    public function index(){
        $coaches = Coach::where(['is_enable' => true, 'type' => Coach::TYPE_PRIVATE_COACH])
            ->orderByDesc('sort')
            ->orderByDesc('created_at')
            ->get();
        return api()->success(CoachResource::collection($coaches));
    }

    public function show($id)
    {
        $coach = Coach::findOrFail($id);
        return api()->success(new CoachResource($coach));
    }
}
